// 用于定义服务器返回的数据类型
/** 
let person1: { name: string; age: number; sex: boolean } = {
  name: '张三',
  age: 20,
  sex: true
}
*/

type Person = {
  name: string
  age: number
  sex: boolean
  address?: { province: string; city: string } // 可选属性
}

let person2: Person = {
  name: '张三',
  age: 20,
  sex: true,
  address: {
    province: '湖南',
    city: '娄底'
  }
}

let person3: Person = {
  name: '李四',
  age: 13,
  sex: false
}

console.log(person2, person3)

type Point2D = { x: number; y: number }
// type Point3D = { x: number; y: number; z: number }

// 对象中没有接口中的继承，但是它提供了交叉语法【提供了所谓的组合功能】
type Point3D = Point2D & { z: number }
let p3: Point3D = { x: 100, y: 100, z: 100 }

export {}
